package com.lonty.intelligence.service;

import com.lonty.intelligence.mapper.StreetNotificationMapper;
import com.lonty.intelligence.model.StreetNotification;
import com.lonty.intelligence.request.StreetNotificationLogo;
import com.lonty.intelligence.util.UUIDUtil;
import com.lonty.intelligence.vo.StreetNotificationVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @Author 陈璇
 * @Date 2020/6/28 15:32
 * @Version 1.0
 */
@Service
public class StreetNotificationService {

    @Resource
    private StreetNotificationMapper streetNotificationMapper;

    /**
     * 保存街道通知
     * @param streetNotificationVo
     * @return
     */
    public boolean saveStreetNotification(StreetNotificationVo streetNotificationVo){
        StreetNotification streetNotification = new StreetNotification();
        BeanUtils.copyProperties(streetNotificationVo, streetNotification);
        streetNotification.setId(UUIDUtil.randomID());
        streetNotification.setCreateTime(LocalDateTime.now());
        streetNotification.setIsDel(0);
        return streetNotificationMapper.saveStreetNotification(streetNotification) > 0;
    }

    /**
     * 根据类型获取通知列表
     * @param type
     * @param userInfoId
     * @return
     */
    public List<StreetNotification> getStreetNotification(Integer type, String userInfoId){
        return streetNotificationMapper.getStreetNotification(type, userInfoId);
    }

    /**
     * 获取首页轮播图
     * @return
     */
    public List<StreetNotificationLogo> getLogoList(){
        return streetNotificationMapper.getLogoList();
    }

}
